<?php

declare(strict_types=1);

namespace App\Exchange\Model;

use App\Fastapp\Model\Currency;
use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\Database\Model\Relations\HasOne;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property int $legal_id 法币id
 * @property int $is_trade 开启现货交易
 * @property int $is_contract 开启合约交易
 * @property int $is_futures 开启期权交易
 * @property int $sort 排序
 * @property int $status 1正常
 */
class ExchangePair extends MineModel
{
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'exchange_pair';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'legal_id', 'is_trade', 'is_contract', 'is_futures', 'sort', 'status'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'legal_id' => 'integer', 'is_trade' => 'integer', 'is_contract' => 'integer', 'is_futures' => 'integer', 'sort' => 'integer', 'status' => 'integer'];

    public function pairList(): HasMany
    {
        return $this->hasMany(ExchangePairList::class, 'legal_id', 'legal_id');
    }

    public function currency(): HasOne
    {
        return $this->hasOne(Currency::class, 'id', 'legal_id');
    }
}
